﻿Ext.Loader.setPath('Happy', '../../src');
Ext.require('Happy.form.field.CkEditor');

Ext.onReady(function () {
    Ext.create('Ext.container.Viewport', {
        layout: 'fit',
        items: {
            xtype: 'form',
            title: 'html 编辑器演示',
            items: [{
                fieldLabel: '文章内容',
                xtype: 'happy-ckeditor',
                value: '<b>你好</b>'
            }],
            buttons: [
                {
                    text: '禁用',
                    handler: function () {
                        this.up('form').down('happy-ckeditor').disable();
                    }
                },
                {
                    text: '启用', handler: function () {
                        this.up('form').down('happy-ckeditor').enable();
                    }
                },
                {
                    text: '只读', handler: function () {
                        this.up('form').down('happy-ckeditor').setReadOnly(true);
                    }
                },
                {
                    text: '可写', handler: function () {
                        this.up('form').down('happy-ckeditor').setReadOnly(false);
                    }
                },
                {
                    text: '写入', handler: function () {
                        this.up('form').down('happy-ckeditor').setValue("<p>你好，世界。</p>");
                    }
                },
                {
                    text: '读取', handler: function () {
                        Ext.Msg.show({
                            title: '内容',
                            msg: this.up('form').down('happy-ckeditor').getValue()
                        });
                    }
                }
            ]
        }
    });
});